﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using System.Data;

namespace DAL
{
    public class userAccess
    {
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="logins"></param>
        /// <returns></returns>
        public static int userRegister(TBLogins logins)
        {
            object count = sqlHelper.ExecuteScalar($"select count(*)from TBLogins where UserName='{logins.UserName}' or MobileNumber='{logins.MobileNumber}'", false);
            if (Convert.ToInt32(count) <= 0)//如果不存在重复的用户名、手机号，即可继续注册
            {
                string sql = $"insert into TBLogins values('{logins.UserName}','{logins.MobileNumber}','{logins.Password}')";
                return sqlHelper.ExecuteNonQuery(sql, false);
            }
            else
            {
                return -1;
            }

        }
    }
}
